package enumDemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Constant {
    public static final int RED = 1;
    public static final int WHITE = 2;
    public static final int GREEN = 3;

    public static void main(String[] args) {
        try {
            Class<?> c = Class.forName("enumDemo.TestEnum");
            Constructor constructor = c.getDeclaredConstructor(String.class,int.class,String.class,int.class);
            constructor.setAccessible(true);
            //不能通过反射创建枚举对象
        TestEnum testEnum = (TestEnum) constructor.newInstance("hello",88,"ceshi",99);
            System.out.println(testEnum);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}
